﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace QuanLyQuangCao
{
    public partial class frmGD_KH_Edit : Form
    {
        public string pMaKH = "";
        public string pTenKH = "";
        public int pTK ;

        public frmGD_KH_Edit()
        {
            InitializeComponent();
        }

        private void textBox1_TextChanged(object sender, EventArgs e)
        {

        }

        private void btnOK_Click(object sender, EventArgs e)
        {
            int tsCK = Convert.ToInt32(txtTK.Text);
            string sql = "update khachhang" + " set Chiet_Khau ='" + tsCK + "'" + "where Ma_Khach= '" + pMaKH + "'";
            SqlConnection sc = new SqlConnection(frmChinh.me.sqlcon);
            SqlCommand sqlCmd = new SqlCommand(sql, sc);
            sc.Open();
            sqlCmd.ExecuteNonQuery();
            sc.Close();
            MessageBox.Show("Bạn Đã Cập Nhật Thành Công", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
            this.Close();
        }

        private void frmGD_KH_Edit_Load(object sender, EventArgs e)
        {
            prvSetData();
            txtMaKH.Enabled = false;
            txtTenKH.Enabled = false;
        }
        private void prvSetData()
        {
            txtMaKH.Text = pMaKH;
            txtTenKH.Text = pTenKH;
            txtTK.Text = pTK.ToString();
        }

        private void txtTK_KeyPress(object sender, KeyPressEventArgs e)
        {
            int p = (int)e.KeyChar;
            if (!(((p >= 48) && (p <= 57)) || (p == 8)))
                e.Handled = true;
        }
    }
}
